home *** CD-ROM | disk | FTP | other *** search
- (*********************************************************************
- *
- * PROGRAM NAME: PLAYVOCX.PAS
- *
- * COMPILER: Borland Turbo Pascal ver. 4 or later
- *
- * DESCRIPTION: Plays a .VOC file from extended memory using the
- * CT-VOICE.DRV driver (accessed from SBSIM). To run
- * the program, type the following at the command line:
- *
- * PLAYVOCX FILENAME
- *
- * Where FILENAME is the drive/path/filename of the .VOC
- * file to play.
- *
- * NOTE: SBSIM driver must be loaded before running this program.
- *
- *********************************************************************)
-
- program playvocx;
- uses dos,crt;
-
- const VOC_MEM_DRIVER = $04;
-
- {$I drvrfunc.pas}
-
- var Command:char;
- UserQuit:boolean;
- RetValue:simerr;
- FileName:string;
- FileHandle:integer;
- SBSIMHandle:integer;
-
- (********************************************************************)
- begin (* main *)
-
- if paramcount <> 1 (* no. of parameters entered on command line *)
- then begin
- writeln('Command line must contain EXACTLY ONE filename parameter!');
- halt; (* Terminate program *)
- end;
-
- (*--- SEE IF SBSIM DRIVER HAS LOADED --*)
- SIMint := FindDvr('SBSIM', $0103); (* Get SBSIM's interrupt no. *)
- if SIMint = 0
- then begin
- writeln('SBSIM driver not loaded!');
- halt; (* Terminate program *)
- end;
-
- (*--- SEE IF CT-VOICE.DRV DRIVER HAS LOADED -------*)
- if (GetDrvrs and VOC_MEM_DRIVER) <> VOC_MEM_DRIVER
- then begin
- writeln('CT-VOICE.DRV not loaded!');
- halt; (* Terminate program *)
- end;
-
- (*--- OPEN FILE SPECIFIED ON COMMAND LINE ------*)
- FileHandle := DosOpen(paramstr(1), ReadAccess);
- if (FileHandle = -1)
- then begin
- writeln('FILE: ',paramstr(1), ' not successfully opened!');
- halt; (* Terminate program *)
- end;
-
- DosClose(FileHandle); (* Done with the file, close it! *)
-
-
- Filename:=paramstr(1); (* copy to string with more space before modifying *)
-
- (*--- LOAD THE FILE INTO EXTENDED MEMORY ----------*)
- if not LoadExtMem(AsciiZ(Filename), SBSIMHandle)
- then begin
- writeln('ERROR CALLING SBSIM: ', errorMsg[simerr(SBSIMHandle)]);
- halt; (* Terminate program *)
- end;
-
-
- (*--- StartSnd() INITIALIZES THE CT-VOICE DRIVER -----------*)
- RetValue := StartSnd(MemVoice, nil, true, SBSIMHandle);
- if RetValue <> SIMerr_NoErr
- then begin
- writeln('ERROR CALLING SBSIM: ', errorMsg[RetValue]);
- halt; (* Terminate program *)
- end;
-
- (*--- PlaySnd() BEGINS PLAYING OF THE FILE ----------*)
- RetValue := PlaySnd(MemVoice);
- if RetValue <> SIMerr_NoErr
- then begin
- writeln('ERROR CALLING SBSIM: ', errorMsg[RetValue]);
- if FreeExtMem(SBSIMHandle) <> SIMerr_NoErr
- then writeln('ERROR: Error freeing extended memory');
- halt; (* Terminate program *)
- end;
-
-
- clrscr; (* Clear screen *)
- writeln(#10#10#10#10#10' SELECT ONE OF THE FOLLOWING OR WAIT UNTIL DONE:');
- writeln(' (P)ause');
- writeln(' (R)esume');
- writeln(' (Q)uit');
-
- UserQuit := false;
-
- (*--- PROCESS USER INTERACTION OR WAIT FOR SOUND TO STOP -----------*)
- repeat
- if (keypressed) (* Was a key pressed? *)
- then begin
- Command := upcase(readkey); (* Get char that's in buffer *)
- if Command = 'P'
- then PauseSnd(MemVoice)
- else if Command = 'R'
- then ResumeSnd(MemVoice)
- else if Command = 'Q'
- then UserQuit := true;
- end;
- (* Exit do-while loop if file is done playing or user typed 'Q' *)
- until (UserQuit = true) or (GetSndStat(MemVoice) = 0);
-
- (*--- IF SOUND IS STILL PLAYING AND USER HIT 'Q', STOP THE SOUND ---*)
- if (GetSndStat(MemVoice) <> 0) and (UserQuit = true)
- then StopSnd(MemVoice);
-
- (*--- FREE UP EXTENDED MEMORY THAT FILE WAS LOADED INTO ------------*)
- if FreeExtMem(SBSIMHandle) <> SIMerr_NoErr
- then writeln('ERROR: Error freeing extended memory');
-
- end.